import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { TechnicianApi } from '#/api/spa/technicians/technician/index';

import { z } from '#/adapter/form';
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
import { DICT_SPA_TYPE } from '#/utils/dictSpa';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'technicianCode',
      label: '技师编号',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入技师编号',
      },
    },
    {
      fieldName: 'employeeId',
      label: '员工ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入员工ID',
      },
    },
    {
      fieldName: 'userId',
      label: '用户ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入用户ID',
      },
    },
    {
      fieldName: 'name',
      label: '姓名',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入姓名',
      },
    },
    {
      fieldName: 'gender',
      label: '性别',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入性别',
      },
    },
    {
      fieldName: 'phone',
      label: '手机号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入手机号',
      },
    },
    {
      fieldName: 'idCard',
      label: '身份证号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入身份证号',
      },
    },
    {
      fieldName: 'birthDate',
      label: '出生日期',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'hireDate',
      label: '入职日期',
      rules: 'required',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'department',
      label: '部门',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入部门',
      },
    },
    {
      fieldName: 'position',
      label: '职位',
      component: 'Input',
      componentProps: {
        placeholder: '请输入职位',
      },
    },
    {
      fieldName: 'orgId',
      label: '组织ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入组织ID',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'skillLevel',
      label: '技能等级',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入技能等级',
      },
    },
    {
      fieldName: 'specialties',
      label: '专长项目',
      component: 'Input',
      componentProps: {
        placeholder: '请输入专长项目',
      },
    },
    {
      fieldName: 'certifications',
      label: '专业认证',
      component: 'Input',
      componentProps: {
        placeholder: '请输入专业认证',
      },
    },
    {
      fieldName: 'languages',
      label: '语言能力',
      component: 'Input',
      componentProps: {
        placeholder: '请输入语言能力',
      },
    },
    {
      fieldName: 'workExperience',
      label: '工作经验(年)',
      component: 'Input',
      componentProps: {
        placeholder: '请输入工作经验(年)',
      },
    },
    {
      fieldName: 'status',
      label: '状态',
      rules: 'required',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'workloadLevel',
      label: '工作负荷等级',
      component: 'Input',
      componentProps: {
        placeholder: '请输入工作负荷等级',
      },
    },
    {
      fieldName: 'salary',
      label: '基本工资',
      component: 'Input',
      componentProps: {
        placeholder: '请输入基本工资',
      },
    },
    {
      fieldName: 'commissionRate',
      label: '提成比例',
      component: 'Input',
      componentProps: {
        placeholder: '请输入提成比例',
      },
    },
    {
      fieldName: 'hourlyRate',
      label: '小时费率',
      component: 'Input',
      componentProps: {
        placeholder: '请输入小时费率',
      },
    },
    {
      fieldName: 'overallRating',
      label: '综合评分',
      component: 'Input',
      componentProps: {
        placeholder: '请输入综合评分',
      },
    },
    {
      fieldName: 'ratingBreakdown',
      label: '评分明细节',
      component: 'Input',
      componentProps: {
        placeholder: '请输入评分明细节',
      },
    },
    {
      fieldName: 'workSchedule',
      label: '工作排班JSON',
      component: 'Input',
      componentProps: {
        placeholder: '请输入工作排班JSON',
      },
    },
    {
      fieldName: 'preferredServices',
      label: '偏好服务JSON',
      component: 'Input',
      componentProps: {
        placeholder: '请输入偏好服务JSON',
      },
    },
    {
      fieldName: 'serviceTypes',
      label: '服务类型',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务类型',
      },
    },
    {
      fieldName: 'totalServicesCount',
      label: '累计服务次数',
      component: 'Input',
      componentProps: {
        placeholder: '请输入累计服务次数',
      },
    },
    {
      fieldName: 'totalServiceHours',
      label: '累计服务时长(小时)',
      component: 'Input',
      componentProps: {
        placeholder: '请输入累计服务时长(小时)',
      },
    },
    {
      fieldName: 'lastServiceDate',
      label: '最后服务日期',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'currentRoomId',
      label: '当前房间ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入当前房间ID',
      },
    },
    {
      fieldName: 'currentServiceId',
      label: '当前服务ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入当前服务ID',
      },
    },
    {
      fieldName: 'currentServiceStartTime',
      label: '当前服务开始时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'monthlyPerformanceScore',
      label: '月度绩效评分',
      component: 'Input',
      componentProps: {
        placeholder: '请输入月度绩效评分',
      },
    },
    {
      fieldName: 'quarterlyPerformanceScore',
      label: '季度绩效评分',
      component: 'Input',
      componentProps: {
        placeholder: '请输入季度绩效评分',
      },
    },
    {
      fieldName: 'yearlyPerformanceScore',
      label: '年度绩效评分',
      component: 'Input',
      componentProps: {
        placeholder: '请输入年度绩效评分',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'technicianCode',
      label: '技师编号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入技师编号',
      },
    },
    {
      fieldName: 'employeeId',
      label: '员工ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入员工ID',
      },
    },
    {
      fieldName: 'userId',
      label: '用户ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入用户ID',
      },
    },
    {
      fieldName: 'name',
      label: '姓名',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入姓名',
      },
    },
    {
      fieldName: 'gender',
      label: '性别',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入性别',
      },
    },
    {
      fieldName: 'phone',
      label: '手机号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入手机号',
      },
    },
    {
      fieldName: 'idCard',
      label: '身份证号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入身份证号',
      },
    },
    {
      fieldName: 'birthDate',
      label: '出生日期',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'hireDate',
      label: '入职日期',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'department',
      label: '部门',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入部门',
      },
    },
    {
      fieldName: 'position',
      label: '职位',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入职位',
      },
    },
    {
      fieldName: 'orgId',
      label: '组织ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入组织ID',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'skillLevel',
      label: '技能等级',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入技能等级',
      },
    },
    {
      fieldName: 'specialties',
      label: '专长项目',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入专长项目',
      },
    },
    {
      fieldName: 'certifications',
      label: '专业认证',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入专业认证',
      },
    },
    {
      fieldName: 'languages',
      label: '语言能力',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入语言能力',
      },
    },
    {
      fieldName: 'workExperience',
      label: '工作经验(年)',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入工作经验(年)',
      },
    },
    {
      fieldName: 'status',
      label: '状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择状态',
      },
    },
    {
      fieldName: 'workloadLevel',
      label: '工作负荷等级',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入工作负荷等级',
      },
    },
    {
      fieldName: 'salary',
      label: '基本工资',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入基本工资',
      },
    },
    {
      fieldName: 'commissionRate',
      label: '提成比例',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入提成比例',
      },
    },
    {
      fieldName: 'hourlyRate',
      label: '小时费率',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入小时费率',
      },
    },
    {
      fieldName: 'overallRating',
      label: '综合评分',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入综合评分',
      },
    },
    {
      fieldName: 'ratingBreakdown',
      label: '评分明细节',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入评分明细节',
      },
    },
    {
      fieldName: 'workSchedule',
      label: '工作排班JSON',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入工作排班JSON',
      },
    },
    {
      fieldName: 'preferredServices',
      label: '偏好服务JSON',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入偏好服务JSON',
      },
    },
    {
      fieldName: 'serviceTypes',
      label: '服务类型',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务类型',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'totalServicesCount',
      label: '累计服务次数',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入累计服务次数',
      },
    },
    {
      fieldName: 'totalServiceHours',
      label: '累计服务时长(小时)',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入累计服务时长(小时)',
      },
    },
    {
      fieldName: 'lastServiceDate',
      label: '最后服务日期',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'currentRoomId',
      label: '当前房间ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入当前房间ID',
      },
    },
    {
      fieldName: 'currentServiceId',
      label: '当前服务ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入当前服务ID',
      },
    },
    {
      fieldName: 'currentServiceStartTime',
      label: '当前服务开始时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'monthlyPerformanceScore',
      label: '月度绩效评分',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入月度绩效评分',
      },
    },
    {
      fieldName: 'quarterlyPerformanceScore',
      label: '季度绩效评分',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入季度绩效评分',
      },
    },
    {
      fieldName: 'yearlyPerformanceScore',
      label: '年度绩效评分',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入年度绩效评分',
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<TechnicianApi.Technician>['columns'] {
  return [
    {
      field: 'id',
      title: '主键ID',
      minWidth: 120,
    },
    {
      field: 'technicianCode',
      title: '技师编号',
      minWidth: 120,
    },
    {
      field: 'employeeId',
      title: '员工ID',
      minWidth: 120,
    },
    {
      field: 'userId',
      title: '用户ID',
      minWidth: 120,
    },
    {
      field: 'name',
      title: '姓名',
      minWidth: 120,
    },
    {
      field: 'gender',
      title: '性别',
      minWidth: 120,
    },
    {
      field: 'phone',
      title: '手机号',
      minWidth: 120,
    },
    {
      field: 'idCard',
      title: '身份证号',
      minWidth: 120,
    },
    {
      field: 'birthDate',
      title: '出生日期',
      minWidth: 120,
    },
    {
      field: 'hireDate',
      title: '入职日期',
      minWidth: 120,
    },
    {
      field: 'department',
      title: '部门',
      minWidth: 120,
    },
    {
      field: 'position',
      title: '职位',
      minWidth: 120,
    },
    {
      field: 'orgId',
      title: '组织ID',
      minWidth: 120,
    },
    {
      field: 'storeId',
      title: '门店ID',
      minWidth: 120,
    },
    {
      field: 'skillLevel',
      title: '技能等级',
      minWidth: 120,
    },
    {
      field: 'specialties',
      title: '专长项目',
      minWidth: 120,
    },
    {
      field: 'certifications',
      title: '专业认证',
      minWidth: 120,
    },
    {
      field: 'languages',
      title: '语言能力',
      minWidth: 120,
    },
    {
      field: 'workExperience',
      title: '工作经验(年)',
      minWidth: 120,
    },
    {
      field: 'status',
      title: '状态',
      minWidth: 120,
    },
    {
      field: 'workloadLevel',
      title: '工作负荷等级',
      minWidth: 120,
    },
    {
      field: 'salary',
      title: '基本工资',
      minWidth: 120,
    },
    {
      field: 'commissionRate',
      title: '提成比例',
      minWidth: 120,
    },
    {
      field: 'hourlyRate',
      title: '小时费率',
      minWidth: 120,
    },
    {
      field: 'overallRating',
      title: '综合评分',
      minWidth: 120,
    },
    {
      field: 'ratingBreakdown',
      title: '评分明细节',
      minWidth: 120,
    },
    {
      field: 'workSchedule',
      title: '工作排班JSON',
      minWidth: 120,
    },
    {
      field: 'preferredServices',
      title: '偏好服务JSON',
      minWidth: 120,
    },
    {
      field: 'serviceTypes',
      title: '服务类型',
      minWidth: 120,
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'totalServicesCount',
      title: '累计服务次数',
      minWidth: 120,
    },
    {
      field: 'totalServiceHours',
      title: '累计服务时长(小时)',
      minWidth: 120,
    },
    {
      field: 'lastServiceDate',
      title: '最后服务日期',
      minWidth: 120,
    },
    {
      field: 'currentRoomId',
      title: '当前房间ID',
      minWidth: 120,
    },
    {
      field: 'currentServiceId',
      title: '当前服务ID',
      minWidth: 120,
    },
    {
      field: 'currentServiceStartTime',
      title: '当前服务开始时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'monthlyPerformanceScore',
      title: '月度绩效评分',
      minWidth: 120,
    },
    {
      field: 'quarterlyPerformanceScore',
      title: '季度绩效评分',
      minWidth: 120,
    },
    {
      field: 'yearlyPerformanceScore',
      title: '年度绩效评分',
      minWidth: 120,
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
